import { resources, SpriteFrame } from 'cc'
import Singleton from '../base/Singleton'
/** 中间层 获取资源 */
export default class ResourceMgr extends Singleton {
  static get Instance() {
    return super.getInstance<ResourceMgr>()
  }

  loadSpriteFrame(path: string, type: typeof SpriteFrame = SpriteFrame) {
    return new Promise<SpriteFrame[]>((resolve, reject) => {
      // 加载图片
      resources.loadDir(path, type, (err, data) => {
        if (err) {
          reject(err)
          return
        }
        resolve(data)
      })
    })
  }
}
